@include('admin.header')

<style type="text/css">
  .opartion {
    width: 350px;
  }

  .pagination {
    list-style: none;
    float: right;
  }

  .pagination li {
    float: left;
    padding-left: 5px;
    padding-right: 5px;
  }

  .input_search {
    margin-top: 10px;
  }
</style>

<div class="wrap">
  <div class="margin-bottom-20">
    <!-- <a class="btn btn-primary edit"><i class="fa fa-plus"></i> 添加</a> -->
    {{ csrf_field() }}
    <input id="change_url" value="" type="hidden"/>
    <form action="{{url('basiconfig/transfer_reason')}}" method="post">
        <div class="cl pd-5 bg-1 bk-gray mt-20">

          转账原因：
       <input type="text" name="reson_name" value="{{$reson_name or ''}}"/>
        
      
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
       
         原因编码：
       <input type="text" name="reson_code" value="{{$reson_code or ''}}"/>
        <br/>

         业务编号：
       <input type="text" name="business_id" value="{{$business_id or ''}}"/>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;

           状态：
        <select name="status" style="width: 120px;">
          <option value=''>--请选择--</option>
          <option value='0_禁用' @if($status=='禁用'){echo selected="selected";} @endif>禁用</option>
          <option value='1_启用' @if($status=='启用'){echo selected="selected";} @endif>启用</option>
          <option value='2_删除' @if($status=='删除'){echo selected="selected";} @endif>删除</option>
        </select>

          &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
            <span class="text-c">
            <button name="" id="search" class="btn btn-success user_search" type="
            submit"><i class="Hui-iconfont"></i> 搜索</button>
            </span>
            <span class="r">共有数据：<strong>{{$data->total()}}</strong> 条</span>
        </div>
    </form>
      <div class="cl pd-5 bg-1 bk-gray mt-20"> <span class="l"><a class="btn btn-primary radius" id="add_reason">添加</a></span> </div>
  </div>
  <form class="form-horizontal js-ajax-form" method="post" novalidate="novalidate">
    <table class="table table-hover table-bordered">
      <thead>
      <tr>
        <th>原因编码</th>
        <th>转账原因</th>
        <th>原因编码 </th>
        <th>业务编号</th>
        <th>状态</th>
        <th>备注</th>
        <th>创建时间</th>
        <th>操作</th>
      </tr>
      </thead>
      <tbody>
      @foreach($data as $val)
      <tr>
        <td>{{$val->reson_id}}</td>
        <td>{{$val->reson_name}}</td>
        <td>{{$val->reson_code}}</td>
        <td>{{$val->business_id}}</td>
        <td>
          @if($val->status == 0)
              <span>禁用</span>
          @elseif($val->status == 1)
              <span>启用</span>
          @else
              <span>删除</span>    
          @endif
        </td>
   
        <td>{{$val->remarks}}</td>
        <td>{{$val->create_time}}</td>
        <td>
         <span><a _id="{{$val->reson_id}}" class="edit_reason">编辑</a></span> ｜
          <a href="javascript:void(0)" rel="{{$val->reson_id}}" class="js-reason-delete">删除</a>
        </td>
      </tr>
      @endforeach
      </tbody>
    </table>

    <!-- 分页 -->
    @if (!empty($data))
    <div class="page_list">
        {{$data->links()}}
    </div>
    @endif
  </form>
</div>

<script>
$(function(){
      //添加原因
    $('#add_reason').click(function() {
      open_iframe_layer('/basiconfig/add_reason');
    });

    //编辑转账原因呢
    $('.edit_reason').click(function() {
      var id = $(this).attr('_id') || 0;
      open_iframe_layer('/basiconfig/add_reason?reson_id='+id);
    });

    $('.js-reason-delete').click(function(){
    var id = $(this).attr('rel');
    layer.confirm('你确定要删除吗？', {
      btn: ['确定','取消']
    }, function(){
      $.post('{{asset("basiconfig/delreason")}}',{id:id},function (msg) {
        if(msg.status == 1){
          layer.alert(msg.info, {
            title: '提示',
            icon: 1,
          });
          window.location.href = '{{asset("basiconfig/transfer_reason")}}';
        }else{
          layer.alert(msg.info, {
            title: '提示',
            icon: 2,
          });
        }
      },'json');
    },function() {

    });
  });
});
//详情
// $('.apply_action').click(function() {
//   var id = $(this).attr('_id');
//    if(confirm("确定要审核通过吗？")){
//       $.ajax({
//             type: 'GET',
//             url: '/system/apply_action?id='+id,
//             dataType: 'json',
//             success: function(data){
               
//             },
           
//          });
//    }
        
//    });


</script>